package com.vast.controller;

import com.vast.entity.ProblemEntity;
import com.vast.service.ProblemService;
import common.utils.Result;
import common.utils.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.*;

import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/problem")
@CrossOrigin
public class ProblemController {

    @Autowired
    ProblemService problemService;
    @Autowired
    MongoTemplate mongoTemplate;

    /**
     * 查询所有问题
     * @param problemEntity
     * @return
     */
    @PostMapping("/problemList")
    public Result getProblemList(@RequestBody ProblemEntity problemEntity){
       Result list= problemService.getProblemList(problemEntity);
        return list;
    }

    /**
     * 添加问题
     * @param problemEntity
     * @return
     */
    @PostMapping("/saveProblem")
    public Result saveProblemList(@RequestBody ProblemEntity problemEntity){
        mongoTemplate.save(problemEntity);
        return  new Result(StatusCode.OK,"问题数据添加成功",true);
    }

}
